<?php
/**
 * template name: testimonial
 * 
 * @author: Tuan
 */
get_header();


if (( isset($_POST['katb_submitted'])) || (isset($_POST['katb_reset']))) {
    echo "<script>
	        
			jQuery(document).ready(function(){
				 jQuery('#form-testimonial').show();
				 }
			);
		</script>";
}
?>
<!-- get ajax arrange col3 -->
<style>
    .block {
        position: absolute;
        padding:0;
        width: 310px;
        padding-left:10px;
        padding-bottom:10px;
    }
</style>

<!-- get ajax arrange  col3 -->
<script type="text/javascript" language="javascript" src="<?php bloginfo('template_directory') ?>/js/jquery-1.8.2.min.js"></script>
<div class="content">
    <div class="container">
        <div class="box-main">
            <div class="row">
                <div class="col-md-9">
                    <div class="tab">
                        <a href="#">Home / </a> <?php echo $post->post_title ?> </div>
                    <h2><?php echo $post->post_title ?> </h2>
                    <br/>
                    <div class="text-content">
                        <div> 
                            <a href="javascript:void(0)" id="show-form-testimonial" class="button"><i class="icon-plus icon-white"></i> Add Testimonial</a>
                            <div id="form-testimonial" style="display: none; overflow:hidden; min-height:20px;">
                                <?php echo do_shortcode('[katb_input_testimonials group="All" ]') ?>
                            </div>
                            <?php
                            $testimonials = Testimonial::AllgetRecord();
                            //print_r($testimonials);
                            // echo do_shortcode('[katb_testimonial group="all" number="all" by="order" id="" rotate="no" display_avatar="true"]')
                            ?>

                        </div>
                        <br clear="all"/>
                        <div style="position: relative;">
                                <?php
                                if ($testimonials > 0) {
                                    foreach ($testimonials as $item) {
                                        $tb_id = $item->tb_id;
                                        $date = $item->tb_date;
                                        $date = date('M d,Y', strtotime($date));
                                        if ($item->tb_pic_url == "") {
                                            $url_img = get_site_url() . '/wp-content/themes/gorave/upload/default_pic.png';
                                        } else {
                                            $url_img = $item->tb_pic_url;
                                        }
                                        ?>
                                        <div style="border-bottom: 1px solid gray;margin-bottom: 10px;;margin-top: 10px;">
                                            <table style=" width: 100%"><tr>
                                            <td style="padding: 5px; width:88px;">
                                                
                                                <img style=" background: none repeat scroll 0 0 #FFFFFF;
                                                     border: 1px solid #D9EAF9;
                                                     border-radius: 10px 10px 10px 10px;
                                                     box-shadow: 0 0 1em #454545; border: none;" width="73px;" src="<?php echo $url_img; ?>" />
                                               
                                            </td>
                                            <td style="padding: 5px;" valign="top">
                                                <div  class="testeminal1"> <p class="name_testimonals"><?php echo trim($item->tb_name); ?></p></div>
                                                <div class="float_right  testeminal_date">Date :<?php echo $date; ?></div>
                                                <br clear="all">
                                                <div class="title-custom" style="margin-top: -12px;"><?php
                                                    $content_testimonals = $item->tb_testimonial;
                                                    $content_testimonals = str_replace('\\', '', $content_testimonals);
                                                    // $content_testimonals = cutString(50, $content_testimonals);
                                                    echo $content_testimonals;
                                                    ?></div>
                                                <div class="location_testimonals" >
                                                    <?php // echo trim(substr($item->tb_location, 0, 120)); ?>
                                                    <br/><?php // echo $date;  ?>
                                                </div> 
                                            </td>
                                            </tr></table>
                                        </div>
                                        <?php
                                    }
                                }
                                ?>
                        </div>
<?php //include_once("right-single.php");  ?>
                    </div>
                </div>
<?php
include_once 'right_single.php';
?>
            </div>
        </div>
    </div>
</div>
<?php get_footer(); ?>
<?php
if (isset($_SESSION['success-testimoninal'])) {//when user have added testimonial successfully
    unset($_SESSION['success-testimoninal']);
    ?>
    <div class="modal fade" id="success-testimoninal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel"> Success</h4>
                </div>
                <div class="modal-body">
                    <div class="alert alert-success">
                        You have post successfully. Please wait for activating by admin
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>
    <?php
}
?>

<script type="text/javascript" language="javascript" src="<?php bloginfo('template_directory') ?>/js/bootstrap.js"></script>
<script type="text/javascript">
    jQuery(document).ready(function() {

        jQuery('#show-form-testimonial').click(function() {
            jQuery('#form-testimonial').slideToggle();
        });
        jQuery('#success-testimoninal').modal();
        jQuery('#success-testimonial').modal();
        jQuery('#success-floor').modal();
    });

</script>